<template>
  <div class="header">
    <div class="left"><span class="iconfont">&#xe624;</span></div>
    <div class="input"><span class="iconfont">&#xe632;</span>输入城市/经典/游玩主题</div>
    <router-link to="/city" custom v-slot="{ navigate }">
      <div class="right" @click="navigate">{{ city }}<span class="iconfont">&#xe64a;</span></div>
    </router-link>

    <!--  vue-router 3.x
    <router-link to="/city" tag="div" class="right">{{ this.city }}<span class="iconfont">&#xe64a;</span></router-link> -->
  </div>
</template>

<script>
import { mapState } from 'vuex'
export default {
  name: 'Header',
  computed: {
    ...mapState(['city']),
  },
}
</script>

<style lang="scss" scoped>
// 已经全局配置，下面配置不需要
// @import '../assets/css/varibles.scss'; // 原始写法
// @import '~@/assets/css/varibles.scss'; // 默认别名方式
// @import '~@css/varibles.scss'; // vue.config.js 配置别名后
.header {
  height: 0.86rem;
  line-height: 0.86rem;
  background: $bg;
  color: #fff;
  display: flex;
  .left {
    width: 0.64rem;
    text-align: center;
  }
  .right {
    min-width: 1.04rem;
    padding: 0 0.1rem;
    text-align: center;
    white-space: nowrap;
    span {
      font-size: 0.24rem;
    }
  }
  .input {
    flex: 1;
    background: #fff;
    color: #ccc;
    border-radius: 0.1rem;
    height: 0.64rem;
    padding-left: 0.2rem;
    line-height: 0.64rem;
    margin-top: 0.1rem;
    margin-left: 0.2rem;
    span {
      margin-right: 0.04rem;
    }
  }
}
</style>
